import request from './request.js'
//post 用data传值 get用params传值
export const LoginPost = (data) => {
    return request({
        url: '/login',
        method: 'post',
        data: data
    })
}

export const getMenus = () => {
    return request({
        url: '/menus',
        method: 'get'
    })
}

export const getUserinfo = (data) => {
    return request({
        url: '/users',
        method: 'get',
        params: data
    })
}

export const putUsersState = (data) => {
    return request({
        url: '/users/'+data.id+'/state/'+data.state,
        method: 'put'
    })
}

export const addUsers = (data) => {
    return request({
        url: '/users',
        method: 'post',
        data: data
    })
}

export const editUsers = (data) => {
    return request({
        url: 'users/'+data.id,
        method: 'put',
        data: {
            email: data.email,
            mobile: data.mobile
        }
    })
}

export const deleteUsers = (data) => {
    return request({
        url: 'users/'+data.id,
        method: 'delete'
    })
}

export const roleUsers = (id,rid) => {
    return request({
        url: 'users/'+id+'/role',
        method: 'put',
        data: rid,
    })
}

export const getRights = (type) => {
    return request({
        url: 'rights/'+type,
        method: 'get'
    })
}

export const getRoles = () => {
    return request({
        url: '/roles',
        method: 'get'
    })
}
//新增角色
export const addRoles = (data) => {
    return request({
        url: '/roles',
        method: 'post',
        data: data
    })
}

export const deleteRoles = (id) => {
    return request({
        url: 'roles/'+id,
        method: 'delete'
    })
}

export const editRole = (data) => {
    return request({
        url: 'roles/'+data.id,
        method: 'put',
        data: data
    })
}

export const deleteRoleMin = (data) => {
    return request({
        url: 'roles/'+data.roleId+'/rights/'+data.rightId,
        method: 'delete'
    })
}

export const editRoles = (roleId,arr) => {
    return request({
        url: 'roles/'+roleId+'/rights',
        method: 'post',
        data: arr
    })
}

//商品管理 --- 分类

export const categoriesRq = (data) => {
    return request({
        url: 'categories',
        method: 'get',
        params: data
    })
}

export const sortAdd = (data) => {
    return request({
        url: 'categories',
        method: 'post',
        data: data
    })
}